package com.csist.server;

import com.csist.task.ServerRunnable;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @ClassName Server
 * @Description 文件接收服务器端
 * @Author User
 * @Date 2021/6/9 8:40
 * @ModifyDate 2021/6/9 8:40
 * @Version 1.0
 */
public class Server {
    public static void main(String[] args) {
        ServerSocket server = null;
        try {
            server = new ServerSocket(8888);
            System.out.println("服务器已启动");
            while (true){
                Socket socket = server.accept();
                System.out.println("客户端已连接");
                new Thread(new ServerRunnable(socket)).start();
            }

        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (server!=null) {
                try {
                    server.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
